import request from '../utils/request'

export function loginApi(username: string, password: string) {
  return request.post('/auth/login', { username, password })
}

export function registerApi(user: { username: string; password: string; realName?: string; phone?: string; email?: string }) {
  return request.post('/auth/register', user)
}

export function getUserInfoApi() {
  return request.get('/user/info')
}

export function saveUserInfoApi(user: any) {
  return request.post('/user/info', user)
}

/**
 * 管理员 获取用户列表
 * @param params 
 * @returns 
 */
export function getUserListApi(params: any) {
  return request.get('/user/list', { params })
}

/**
 * 管理员 添加用户
 * @param user 
 * @returns 
 */
export function addUserApi(user: any) {
  return request.post('/user/add', user)
}

/**
 * 管理员 修改用户
 * @param user 
 * @returns 
 */
export function updateUserApi(user: any) {
  return request.post('/user/update', user)
}